package MeroryTest;


/**
 * VM Args：-Xss128k
 * if(栈的深度*栈帧的平均大小 > -Xss的值)，then StackOverflowError
 */
public class StackOverflow {
	//记录栈的深度
	private int stackLength = 1;
	public void test() {
		stackLength++;
		//递归调用，使栈帧爆满
		test();
	}

	public static void main(String[] args) {
		StackOverflow stackOverflow =new StackOverflow();
		
		try {
		stackOverflow.test();
		}catch(Throwable e)
		{
			System.out.println(stackOverflow.stackLength);
			throw e;
		}
	}

}
